<?php

use App\Http\Controllers\AccountController;
use App\Http\Controllers\ArticleCategoryController;
use App\Http\Controllers\ArticleController;
use App\Http\Controllers\ConfigController;
use App\Http\Controllers\IndexController;
use App\Http\Controllers\LoginController;
use App\Http\Controllers\MenuController;
use App\Http\Controllers\RecordController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\TagsController;
use App\Http\Controllers\UploadController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// 首页
Route::get('/', [IndexController::class, 'index'])->middleware('login');

// 首页，默认页，左边菜单页
Route::prefix('index')->middleware('login')->group(function () {
    Route::get("",[IndexController::class,'index']);
    Route::get("index",[IndexController::class,'index'])->name('index');
    Route::get("console",[IndexController::class,'console'])->name('console');
    Route::get("menu",[IndexController::class,'menu']);
});

// 登录，退出，验证码
Route::prefix('login')->group(function () {
    Route::match(['get','post'],'login',[LoginController::class,'login'])->name('login');
    Route::get("captcha",[LoginController::class,'captcha'])->name('captcha');
    Route::get("logout",[LoginController::class,'logout'])->name('logout')->middleware('login');
});

// 上传
Route::prefix('upload')->middleware(['login','check'])->group(function () {
    Route::post("upload",[UploadController::class,'upload'])->name('upload.upload');
    Route::post("image",[UploadController::class,'image'])->name('upload.image');
    Route::post("video",[UploadController::class,'video'])->name('upload.video');
});

// 系统设置
Route::match(['get','post'],'config/edit',[ConfigController::class,'edit'])->name('config.edit')->middleware(['login','check']);

// 操作日志
Route::prefix('record')->middleware(['login','check'])->group(function () {
    Route::get('index',[RecordController::class,'index'])->name('record.index');
    Route::get('list',[RecordController::class,'list'])->name('record.list');
    Route::delete('delete/{id}',[RecordController::class,'delete'])->name('record.delete');
    Route::delete('remove',[RecordController::class,'remove'])->name('record.remove');
    Route::delete('clear',[RecordController::class,'clear'])->name('record.clear');
});

// 菜单管理
Route::prefix('menu')->middleware(['login','check'])->group(function () {
    Route::get('index',[MenuController::class,'index'])->name('menu.index');
    Route::get('list',[MenuController::class,'list'])->name('menu.list');
    Route::get('status/{id}',[MenuController::class,'status'])->name('menu.status');
    Route::match(['get','post'],'add/{id?}',[MenuController::class,'add'])->name('menu.add');
    Route::match(['get','post'],'edit/{id?}',[MenuController::class,'edit'])->name('menu.edit');
    Route::delete('delete/{id}',[MenuController::class,'delete'])->name('menu.delete');
});

// 角色管理
Route::prefix('role')->middleware(['login','check'])->group(function () {
    Route::get('index',[RoleController::class,'index'])->name('role.index');
    Route::get('list',[RoleController::class,'list'])->name('role.list');
    Route::match(['get','post'],'add',[RoleController::class,'add'])->name('role.add');
    Route::match(['get','post'],'edit/{id?}',[RoleController::class,'edit'])->name('role.edit');
    Route::delete('delete/{id}',[RoleController::class,'delete'])->name('role.delete');
});

// 用户管理
Route::prefix('account')->middleware(['login','check'])->group(function () {
    Route::get('index',[AccountController::class,'index'])->name('account.index');
    Route::get('list',[AccountController::class,'list'])->name('account.list');
    Route::get('status/{id}',[AccountController::class,'status'])->name('account.status');
    Route::match(['get','post'],'add',[AccountController::class,'add'])->name('account.add');
    Route::match(['get','post'],'edit/{id?}',[AccountController::class,'edit'])->name('account.edit');
    Route::match(['get','post'],'mod/{id?}',[AccountController::class,'mod'])->name('account.mod');
    Route::delete('delete/{id}',[AccountController::class,'delete'])->name('account.delete');
});

// 文章分类管理
Route::prefix('article_category')->middleware(['login','check'])->group(function () {
    Route::get('index',[ArticleCategoryController::class,'index'])->name('article_category.index');
    Route::get('list',[ArticleCategoryController::class,'list'])->name('article_category.list');
    Route::get('status/{id}',[ArticleCategoryController::class,'status'])->name('article_category.status');
    Route::match(['get','post'],'add',[ArticleCategoryController::class,'add'])->name('article_category.add');
    Route::match(['get','post'],'edit/{id?}',[ArticleCategoryController::class,'edit'])->name('article_category.edit');
    Route::delete('delete/{id}',[ArticleCategoryController::class,'delete'])->name('article_category.delete');
});

// 标签管理
Route::prefix('tags')->middleware(['login','check'])->group(function () {
    Route::get('index',[TagsController::class,'index'])->name('tags.index');
    Route::get('list',[TagsController::class,'list'])->name('tags.list');
    Route::get('status/{id}',[TagsController::class,'status'])->name('tags.status');
    Route::match(['get','post'],'add',[TagsController::class,'add'])->name('tags.add');
    Route::match(['get','post'],'edit/{id?}',[TagsController::class,'edit'])->name('tags.edit');
    Route::delete('delete/{id}',[TagsController::class,'delete'])->name('tags.delete');
    Route::delete('remove/{id}',[TagsController::class,'remove'])->name('tags.remove');
});

// 文章管理
Route::prefix('article')->middleware(['login','check'])->group(function () {
    Route::get('index',[ArticleController::class,'index'])->name('article.index');
    Route::get('list',[ArticleController::class,'list'])->name('article.list');
    Route::get('status/{id}',[ArticleController::class,'status'])->name('article.status');
    Route::match(['get','post'],'add',[ArticleController::class,'add'])->name('article.add');
    Route::match(['get','post'],'edit/{id?}',[ArticleController::class,'edit'])->name('article.edit');
    Route::delete('delete/{id}',[ArticleController::class,'delete'])->name('article.delete');
});
